using System;
using System.Web;
using System.Collections;
using System.Collections.Generic;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Configuration;

using Com.Grubbland.Data.Access;
using Com.Grubbland.Data.Objects;


/// <summary>
/// Summary description for GameBaseService
/// </summary>
[WebService(Namespace = "http://eelms.grubbland.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class GameBaseService : System.Web.Services.WebService
{
    private string _cs = ConfigurationManager.ConnectionStrings["etConnStr"].ConnectionString;
    private GameServiceImpl _svc = null;

    public GameBaseService()
    {
        _svc = new GameServiceImpl(_cs);
    }

    [WebMethod]
    public string HelloWorld()
    {
        return "Hello World";
    }


    [WebMethod]
    public int EnterWaitingRoom( string userId )
    {
        return _svc.EnterWaitingRoom( userId );
    }

    [WebMethod]
    public int ExitGameWaitingRoom(string userId)
    {
        return _svc.ExitGameWaitingRoom(userId);
    }

    [WebMethod]
    public int ExitWaitingRoom( string userId )
    {
        return _svc.ExitWaitingRoom( userId );
    }

    [WebMethod]
    public bool ExitGame( string userId, string sessionId )
    {
        return _svc.ExitGame( userId, sessionId );
    }

    [WebMethod]
    public int JoinGameWaitingList( string userId, string gameId ) 
    {
        return _svc.JoinGameWaitingList( userId, gameId );
    }

    [WebMethod]
    public bool CreateGameByProfile(string gameId, int numUsers)
    {
        return _svc.CreateGameByProfile(gameId, numUsers);
    }

    [WebMethod]
    public int CreateGames()
    {
        return _svc.CreateGames();
    }

    [WebMethod]
    public List<WaitingRoomUser> GetWaitingRoomByGame( string gameId )
    {
        return _svc.GetWaitingRoomByGame(gameId);
    }

    [WebMethod]
    public GameAction PollForGameAction( string sessionId, string userId, int lastKnownTurnId )
    {
        return _svc.PollForGameAction(sessionId, userId, lastKnownTurnId);
    }

    [WebMethod]
    public GameAction PollForGameResponses(string sessionId, int turnId)
    {
        return _svc.PollForGameResponses(sessionId, turnId);
    }

    [WebMethod]
    public string PollForGameStart( string userId, string gameId )
    {
        return _svc.PollForGameStart(userId, gameId);
    }

    [WebMethod]
    public int TakeTurn(string userId, string sessionId, TurnData td)
    {
        return _svc.TakeTurn(userId, sessionId, td);
    }

    [WebMethod]
    public int MarkPlayerReady( string userId, string sessionId )
    {
        return _svc.MarkPlayerReady(userId, sessionId );
    }

    [WebMethod]
    public List<GamePlayer> CheckForPlayersReady(string sessionId)
    {
        return _svc.CheckForPlayersReady(sessionId);
    }
}

